package ai.people.netmon.framework.domain.gang.construction.request;

import ai.people.netmon.framework.domain.gang.construction.entity.RelationRule;
import ai.people.netmon.framework.domain.gang.construction.valid.ValidationGroup;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 关系库-类型
 * </p>
 *
 * @author zhenglin
 * @since 2022-07-19
 */
@Data
public class RelationLibConfigSaveOrUpdateRequest implements Serializable {

    /**
     * id
     */
    @NotNull(message = "id不能为空", groups = ValidationGroup.Update.class)
    private Long id;
    /**
     * 扩线关系点value
     */
    @NotBlank(message = "扩线关系点value不能为空")
    private String expListValue;
    /**
     * 类型value
     */
    @NotBlank(message = "类型value不能为空")
    private String expTypeValue;

    /**
     * 规则ID
     */
    @NotNull(message = "规则ID不能为空")
    private Long relationRuleId;

    /**
     * 配置的规则
     */
    @NotEmpty(message = "配置的规则不能为空")
    @Valid
    private List<RelationRule.Rule> rule;

    public String buildRuleStr() {
        return JSONArray.toJSONString(rule);
    }
}
